const int N = 1e4 + 10;
int sum[N];
class NumArray {
public:
    NumArray(vector<int>& nums) {
        int n = nums.size();
        sum[1] = nums[0];
        for (int i = 2; i <= n; i++) {
            sum[i] = sum[i - 1] + nums[i - 1];
        }
    }

    int sumRange(int left, int right) {
        left++;
        right++;
        return sum[right] - sum[left - 1];
    }
};

/**
 * Your NumArray object will be instantiated and called as such:
 * NumArray* obj = new NumArray(nums);
 * int param_1 = obj->sumRange(left,right);
 */